package com.syn.synold4s.control.dialog;

import android.content.Context;

import com.gaoyi.basemodule.baseUtil.DensityUtil;
import com.gaoyi.basemodule.basedialog.BaseFragmentDialog;
import com.syn.synold4s.R;
import com.syn.synold4s.databinding.AlertDialogBinding;

public class AlertDialog extends BaseFragmentDialog<AlertDialogBinding> {

    private String mWearer = "", mTel = "", mAddress = "",mType = "",mAlertTime = "";

    public AlertDialog(Context context, String wearer, String tel, String address, String type, String alertTime) {
        super(context);
        this.mWearer = wearer;
        this.mTel = tel;
        this.mAddress = address;
        this.mType = type;
        this.mAlertTime = alertTime;
    }

    @Override
    protected void initView() {
        setCanceledOnTouchOutside(false);
        setCancelable(false);
        mBinding.ivClose.setOnClickListener(view -> dismiss());
        setData();
    }

    private void setData() {
        if (mType.equals("Hook")) {
            mBinding.tvAlertTitle.setText(getString(R.string.hook_alert_title, mWearer));
            mBinding.tvAlertContent.setText(getString(R.string.hook_alert_content, mAddress,mAlertTime));
        }else {
            mBinding.tvAlertTitle.setText(getString(R.string.alert_title, mWearer, mTel));
            mBinding.tvAlertContent.setText(getString(R.string.alert_content, mAddress));
        }
    }

    @Override
    protected AlertDialogBinding getViewBinding() {
        return AlertDialogBinding.inflate(getLayoutInflater());
    }

    @Override
    protected int getWidth() {
        return DensityUtil.dp2px(300);
    }

    @Override
    protected String getShowTag() {
        return CENTER;
    }
}
